package com.gubei.subject.domain.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * スレッドプールの構成情報
 */
@Configuration
public class ThreadPoolConfig {
    @Bean(name = "threadPoolExecutor")
    public ThreadPoolExecutor getLabelThreadPool() {
        return new ThreadPoolExecutor(
                20,
                100,
                5,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<Runnable>(40),
                new CustomNameThreadFactory("label"),
                new ThreadPoolExecutor.CallerRunsPolicy());
    }
}
